/**
 * 
 * 广州锐鹏计算机科技有限公司（www.ruipengkj.com）
 * 
 * 
 * Copyright (c) 2011-2012 RUIPENGKJ.Co.Ltd. All rights reserved.
 * 
 * */
package com.ruipengkj.bean;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;

/**
 * 说明：
 * Entity Name 产品目录
 * @Author：李智深
 * @Date：2012-03-14
 */
@Entity
@Table(name="ruipeng_tb_TProductCatalog")
public class TProductCatalog implements Serializable{

	private static final long serialVersionUID = 1L;

	private String CatalogID;//目录编号CHAR(15)PK
	
//	private String ParentCatalogID;//父目录编号
	
	private String Name;//目录名称VARCHAR(256)
	
	private String Des;//目录说明VARCHAR(512)
	
	private int ChildCount;//子目录个数INTEGER
	
	private byte Type;//目录类型TINYINT
	
	private String ClassID;//相关类CHAR(15)
	
	private String RelShopClass;//相关商店类
	
	private String Unit;//商品计量单位VARCHAR(30)目录可以设置默认的计量单位，商品也可以独立设置，一个商品默认的计量单位为该目录的计量单位，如果该目录没有计量单位，则一直往上找，直到找到一个默认计量单位
	
	private Set<TCommodity> TCommoditys=new HashSet<TCommodity>(0);//商品
	
	private TProductCatalog TProductCatalog;//商品父分类
	
	private Set<TProductCatalog> TProductCatalogs=new HashSet<TProductCatalog>(0);//商品子分类

	private String IntoSales;//进销属性-0，标示不设定，1-仅进货，2-仅销售，3-进货销售
	
	private Integer Priority;//仓库优先级INTEGER   用于排序和设置默认。 数值越大则越在前
	
	public TProductCatalog(){}
	
	public TProductCatalog(String catalogID, String name, String des) {
		super();
		CatalogID = catalogID;
		Name = name;
		Des = des;
	}

	public TProductCatalog(String catalogID, String name, String des, Integer Priority) {
		super();
		CatalogID = catalogID;
		Name = name;
		Des = des;
		this.Priority = Priority;
	}
//	public TProductCatalog(String catalogID, String name, String des,
//			String parentID, String parentName, String parentDes) {
//		super();
//		CatalogID = catalogID;
//		Name = name;
//		Des = des;
//		TProductCatalog = new TProductCatalog(parentID, parentName, parentDes);
//	}


	public TProductCatalog(String catalogID){
		this.CatalogID=catalogID;
	}
	
	@Id
	@Column(name = "CatalogID", length=15)
	public String getCatalogID() {
		return CatalogID;
	}

	public void setCatalogID(String catalogID) {
		CatalogID = catalogID;
	}


	@Column(name = "Name", length=256)
	public String getName() {
		return Name;
	}

	public void setName(String name) {
		Name = name;
	}

	@Column(name = "Des", length=512)
	public String getDes() {
		return Des;
	}

	public void setDes(String des) {
		Des = des;
	}

	@Column(name = "ChildCount")
	public int getChildCount() {
		return ChildCount;
	}

	public void setChildCount(int childCount) {
		ChildCount = childCount;
	}

	@Column(name = "Type")
	public byte getType() {
		return Type;
	}

	public void setType(byte type) {
		Type = type;
	}

	@Column(name = "ClassID", length=15)
	public String getClassID() {
		return ClassID;
	}

	public void setClassID(String classID) {
		ClassID = classID;
	}

	@Column(name = "RelShopClass", length=15)
	public String getRelShopClass() {
		return RelShopClass;
	}

	public void setRelShopClass(String relShopClass) {
		RelShopClass = relShopClass;
	}

	@Column(name = "Unit", length=30)
	public String getUnit() {
		return Unit;
	}

	public void setUnit(String unit) {
		Unit = unit;
	}
	
	@Column(name = "IntoSales", length = 6)
	public String getIntoSales() {
		return IntoSales;
	}

	public void setIntoSales(String intoSales) {
		IntoSales = intoSales;
	}
	
	@OneToMany(mappedBy="TProductCatalog", fetch=FetchType.EAGER)
	@JoinColumn(name="CatalogID")
	public Set<TCommodity> getTCommoditys() {
		return TCommoditys;
	}

	public void setTCommoditys(Set<TCommodity> tCommoditys) {
		TCommoditys = tCommoditys;
	}
	
	@ManyToOne
	@JoinColumn(name="TProductCatalogID")
	public TProductCatalog getTProductCatalog() {
		return TProductCatalog;
	}

	public void setTProductCatalog(TProductCatalog tProductCatalog) {
		TProductCatalog = tProductCatalog;
	}
	
	@OneToMany(mappedBy="TProductCatalog")//, fetch=FetchType.EAGER
	@JoinColumn(name="TProductCatalogID")
	@Cascade(value={CascadeType.DELETE})
	public Set<TProductCatalog> getTProductCatalogs() {
		return TProductCatalogs;
	}

	public void setTProductCatalogs(Set<TProductCatalog> tProductCatalogs) {
		TProductCatalogs = tProductCatalogs;
	}
	
	@Column(name = "Priority")
	public Integer getPriority() {
		return Priority;
	}

	public void setPriority(Integer priority) {
		Priority = priority;
	}
}
